﻿
//自动义修改按钮事件
var fnCustomEdit = function () {
    alert("aa");
}

//自定义删除方法
var fnCustomDelete = function () {
    var list = this.mDataTable.getRecordSet()._records;
    var elist = [];
    dl = [];
    for (var i = 0; i < list.length; i++) {
        if (list[i]._oData["iSun_Selected"] == true) {
            elist.push(list[i]._oData[const_entityID]);
            dl.push(list[i]._sId); //获取行ID；
        }
    }
    if (elist.length == 0) {
        var recordID = myDataTable.getSelectedRows()[0];
        record = myDataTable.getRecord(recordID);
        SaveUrl = "AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=delete&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID);
    }
    else {
        SaveUrl = "AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=delete&entity=" + const_EditEntity + "&json=" + elist.join(",");
    }
    YAHOO.example.container.dialog3.show();
}
//删除
function DeleteData() {
    YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
        success: function (res) {
            try {
                var str = res.responseText;

                if (str == "1") {
                    alert("数据删除成功");
                    var recordID = mDataTable.getSelectedRows()[0];
                    if (dl.length == 0) {
                        mDataTable.deleteRow(recordID);
                    }
                    else {
                        for (var i = 0; i < dl.length; i++) {
                            mDataTable.deleteRow(dl[i]);
                        }
                    }
                }
                else {
                    alert(str + "\n" + "数据删除失败!");
                }
            }
            catch (e) {
            }
            finally {
            }
        },
        failure: function (error) {
            alert("数据错误：" + error.statusText);
        }
    }, null);
    YAHOO.example.container.dialog3.hide();
}
